<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改班级上课记录')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-classRecord-edit">
        <input name="claRecordId" th:field="*{teachingClassesRecord.claRecordId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">老师名称：</label>
            <div class="col-sm-8">
                <select class="form-control" id="teacherId" name="teacherId" th:field="${teachingClassesRecord.teacherId}">
                    <option th:each="teacher:${teachers}"
                            th:value="${teacher.userId}"
                            th:text="${teacher.userName}">
                    </option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">老师获得课时：</label>
            <div class="col-sm-8">
                <input name="teacherHour" th:field="*{teachingClassesRecord.teacherHour}" class="form-control"
                       type="number">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "teaching/classRecord";
    $("#form-classRecord-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-classRecord-edit').serializeArray();
            // var teacherId = $("#teacherId option:selected").val();
            var teacherName = $("#teacherId option:selected").text();
            data.push({"name": "teacherName", "value": teacherName});
            $.operate.save(prefix + "/edit", data, function (result) {
                var parent = activeWindow();
                if (result.code == 0) {
                    $.modal.close();
                    parent.location.reload();
                } else {
                    $.modal.alert(result.msg);
                }
            });
        }
    }

    $("input[name='startDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='startTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='endTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>